//#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <queue>
#include <vector>
using namespace std;
int mg[505][505] = { 0 };
bool vis[505][505] = { 0 };
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m, a, b;
	cin >> n >> m >> a >> b;

	queue<pair<int, int>>qb;
	vector<pair<int, int>>v;

	for (int i = 0;i < a;i++) {
		int x, y;
		cin >> x >> y;
		qb.push({ x,y });
		vis[x][y] = true;
	}

	for (int i = 0;i < b;i++) {
		int x, y;
		cin >> x >> y;
		v.push_back({ x,y });
	}
	int dx[] = { 1,0,-1,0 };
	int dy[] = { 0,1,0,-1 };
	while (!qb.empty()) {
		int x = qb.front().first;
		int y = qb.front().second;
		int time = mg[x][y] + 1;
		qb.pop();
		for (int i = 0;i < 4;i++) {
			int tx = x + dx[i];
			int ty = y + dy[i];
			if (tx<1 || ty<1 || tx>n || ty>m|| vis[tx][ty] == true)
				continue;
			qb.push({ tx,ty });
			vis[tx][ty] = true;
			mg[tx][ty] = time;
		}
	}
	for (auto at : v) {
		cout << mg[at.first][at.second] << endl;
	}
	return 0;
}